package iac.gwt.authorization.client.tag;

import iac.gwt.client.IacCrudPanel;
import br.com.iswe.gwt.crud.client.DetailPanel;
import br.com.iswe.gwt.crud.client.SearchPanel;
import br.com.iswe.gwt.ui.client.BeanMap;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class XXX_CrudPanel extends RmCrudPanel {

	private XXX_SearchPanel searchPanel;
	protected SearchPanel getSearchPanel() {
		return searchPanel;
	}
	
	private TabPanel tabPanel;
	protected TabPanel getTabPanel() {
		return tabPanel;
	}
	
	public XXX_CrudPanel() {

		final VerticalPanel verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);

		final AbsolutePanel absolutePanel = new AbsolutePanel();
		verticalPanel.add(absolutePanel);
		absolutePanel.setSize("550", "40");

		final Label screenLabel = new Label("XXX_ Screen : ");
		absolutePanel.add(screenLabel, 10, 10);

		final Hyperlink newItemHyperlink = new Hyperlink("New XXX_", "NEW_XXX_");
		absolutePanel.add(newItemHyperlink, 259, 10);
		newItemHyperlink.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				prepareInsert();
			}
		});

		tabPanel = new TabPanel();
		verticalPanel.add(tabPanel);
		tabPanel.setWidth("600");

		searchPanel = new XXX_SearchPanel();
		tabPanel.add(searchPanel, "Search");
		tabPanel.selectTab(0);
		
		configScrenn();
	}
	
	protected DetailPanel beforeDetail(BeanMap beanMap) {
		XXX_DetailPanel detailPanel = new XXX_DetailPanel();
		detailPanel.detail(beanMap);
		return detailPanel;
	}
	
	
	protected DetailPanel beforeInsert() {
		XXX_DetailPanel detailPanel = new XXX_DetailPanel();
		return detailPanel;
	}
	
	protected String getTabTitle(BeanMap beanMap) {
		if(beanMap != null){
			return "XXX_: " + beanMap.getString("XXX_");
		}
		else{
			return "New XXX_";
		}
	}
	
	
}
